using System;

namespace Abp.Dependency
{
    /// <summary>
    /// Define interface for classes those are used to resolve dependencies.
    /// 定义了该接口的类被用于解析依赖。
    /// </summary>
    public interface IIocResolver
    {
        /// <summary>
        /// Gets an object from IOC container.
        /// Returning object must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取一个对象。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <typeparam name="T">Type of the object to get。要取得对象的类型。</typeparam>
        /// <returns>The object instance。对象实例。</returns>
        T Resolve<T>();

        /// <summary>
        /// Gets an object from IOC container.
        /// Returning object must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取一个对象。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <typeparam name="T">Type of the object to cast。实际返回的对象类型。</typeparam>
        /// <param name="type">Type of the object to resolve。用于解析的对象类型。</param>
        /// <returns>The object instance。对象实例。</returns>
        T Resolve<T>(Type type);

        /// <summary>
        /// Gets an object from IOC container.
        /// Returning object must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取一个对象。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <typeparam name="T">Type of the object to get。要取得对象的类型。</typeparam>
        /// <param name="argumentsAsAnonymousType">Constructor arguments。构造函数参数。</param>
        /// <returns>The object instance。对象实例。</returns>
        T Resolve<T>(object argumentsAsAnonymousType);

        /// <summary>
        /// Gets an object from IOC container.
        /// Returning object must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取一个对象。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <param name="type">Type of the object to get。要取得对象的类型。</param>
        /// <returns>The object instance。对象实例。</returns>
        object Resolve(Type type);

        /// <summary>
        /// Gets an object from IOC container.
        /// Returning object must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取一个对象。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <param name="type">Type of the object to get。要取得对象的类型。</param>
        /// <param name="argumentsAsAnonymousType">Constructor arguments。构造函数参数。</param>
        /// <returns>The object instance。对象实例。</returns>
        object Resolve(Type type, object argumentsAsAnonymousType);

        /// <summary>
        /// Gets all implementations for given type.
        /// Returning objects must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取所有实现。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <typeparam name="T">Type of the objects to resolve。用于解析的对象类型。</typeparam>
        /// <returns>Object instances。对象实例组成的数组。</returns>
        T[] ResolveAll<T>();

        /// <summary>
        /// Gets all implementations for given type.
        /// Returning objects must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取所有实现。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <typeparam name="T">Type of the objects to resolve。用于解析的对象类型。</typeparam>
        /// <param name="argumentsAsAnonymousType">Constructor arguments。构造函数参数。</param>
        /// <returns>Object instances。对象实例组成的数组。</returns>
        T[] ResolveAll<T>(object argumentsAsAnonymousType);

        /// <summary>
        /// Gets all implementations for given type.
        /// Returning objects must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取所有实现。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <param name="type">Type of the objects to resolve。用于解析的对象类型。</param>
        /// <returns>Object instances。对象实例组成的数组。</returns>
        object[] ResolveAll(Type type);

        /// <summary>
        /// Gets all implementations for given type.
        /// Returning objects must be Released (see <see cref="Release"/>) after usage.
        /// 从 IOC 容器中获取所有实现。
        /// 返回对象在使用后必须被释放（参阅 <see cref="Release"/>）。
        /// </summary> 
        /// <param name="type">Type of the objects to resolve。用于解析的对象类型。</param>
        /// <param name="argumentsAsAnonymousType">Constructor arguments。构造函数参数。</param>
        /// <returns>Object instances。对象实例组成的数组。</returns>
        object[] ResolveAll(Type type, object argumentsAsAnonymousType);

        /// <summary>
        /// Releases a pre-resolved object. See Resolve methods.
        /// 释放一个预先解析的对象。参阅 <see cref="Resolve"/> 方法。
        /// </summary>
        /// <param name="obj">Object to be released。将被释放的对象。</param>
        void Release(object obj);

        /// <summary>
        /// Checks whether given type is registered before.
        /// 检查给定类型是否已被注册。
        /// </summary>
        /// <param name="type">Type to check。将要检查的类型。</param>
        bool IsRegistered(Type type);

        /// <summary>
        /// Checks whether given type is registered before.
        /// 检查给定类型是否已被注册。
        /// </summary>
        /// <typeparam name="T">Type to check。将要检查的类型。</typeparam>
        bool IsRegistered<T>();
    }
}